import socket
cs=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
cs.connect(('222.200.50.13',7777))
f=open('D:\\test.rar','wb')
while True:
    data=cs.recv(1024)
    if not data: 
        break
    f.write(data)
 
f.flush()
f.close()
